package com.woniuxy;

import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;

/**
 * @Author: 马宇航
 * @Todo: 解析jwt的值
 * @DateTime: 22/04/13/0013 下午 2:11
 * @Component: 成都蜗牛学苑
 **/
public class ParasJWT {
    public static void main(String[] args) {
        String token = "eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI4NTciLCJzdWIiOiJhZG1pbiIsImlhdCI6MTY0OTgzMDk2MiwibXlNb25leSI6MTg4LCJteU5hbWUiOiLpqazlrofoiKoiLCJteWNpdHkiOiLlm5vlt53nnIEifQ.WainLInsvGzJEuANTc7Hs7izoXfGWDMWFooCY8ZsdyE";
        //signingkey 签名  签名是有唯一性的！
        Claims claims = Jwts.parser().setSigningKey("woniu")
                .parseClaimsJws(token).getBody();
        System.out.println(claims.getId());
        System.out.println("主体是哪个用户："+claims.getSubject());
        System.out.println("签名(生成token)的时间："+claims.getIssuedAt());
        System.out.println(claims.get("myMoney"));
        System.out.println(claims.get("mycity"));
    }
}
